export function ValidateRules() {
  // 下拉输入框的属性校验规则
  const InputSelectValidate = async (
    rule: unknown,
    value: unknown,
    callback: (data?: string) => void
  ) => {
    if (JSON.stringify(value) == "" || JSON.stringify(value) == "{}") {
      callback("");
    }
    callback();
  };
  // 手机号校验规则
  const PhoneValidate = async (
    rule: unknown,
    value: unknown,
    callback: (data?: string) => void
  ) => {
    const reg = /^1[3-9][0-9]\d{8}$/;
    if (!reg.test(value as string) || JSON.stringify(value) === "") {
      callback("");
    }
    callback();
  };
  // 身份证校验规则
  const IDCardValidate = async (
    rule: unknown,
    value: unknown,
    callback: (data?: string) => void
  ) => {
    const reg = /(^\d{15}$)|(^\d{17}([0-9]|X)$)/;
    if (!reg.test(value as string) || JSON.stringify(value) === "") {
      callback("");
    }
    callback();
  };

  return { InputSelectValidate, PhoneValidate, IDCardValidate };
}
